<template>
  <div class="wrap">
    <el-date-picker
      :editable="false"
      v-model="dateValue"
      type="date"
      value-format="yyyy-MM-dd"
      :picker-options="pickerOptions"
      placeholder="选择日期"
      @change="dateChange">
    </el-date-picker>
    
    <el-input placeholder="请输入渠道名称" style="width:200px;" v-model="channelName"></el-input>

    <el-button icon="el-icon-refresh" @click="refreshClick" style="margin-left:20px;">搜索</el-button>

    
    <el-table
      class="table"
      border fit highlight-current-row
      v-loading="loading"
      element-loading-text="加载中"
      element-loading-spinner="el-icon-loading"
      :data="tableData"
      style="width: 100%">
      <el-table-column
          align="center"
          prop="ipAddress"
          label="ip地址">
      </el-table-column>
      <el-table-column
          align="center"
          prop="channelName"
          label="渠道名称">
      </el-table-column>
      <el-table-column
          align="center"
          prop="count"
          label="重复次数">
      </el-table-column>
      <el-table-column
          align="center"
          prop="createTime"
          label="日期">
           <template slot-scope="scope">
            <p> {{_mapping.date_format(scope.row.createTime)}}</p>
          </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="pagination"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="query.pageNum"
      :page-size="query.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalNum">
    </el-pagination>
  </div>
</template>
<script>
import _ipCheck from '@/services/ipCheck.js'
import _mapping from '@/utils/_mapping.js'
export default {
  data(){
    return {
      loading: false,
      tableData: [{
       
      }],
      dateValue:'',
      channelName:'',
      query: {
        pageSize: 30,
        pageNum: 1
      },
      totalNum: 0,
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        }
      }
    }
  },
  methods: {
    handleSizeChange(val) {
      this.query.pageSize = val
      this.getIpCheckList()
    },
    dateChange(val){
      this.getIpCheckList()
    },
    handleCurrentChange(val) {
      this.query.pageNum = val
      this.getIpCheckList()
    },
    // 刷新按钮
    refreshClick(){
      this.getIpCheckList()
    },  // 获取产品下啦
 
    getIpCheckList(){
      let params = {
        "pageNum": this.query.pageNum,
        "pageSize": this.query.pageSize,
        "channelName": this.channelName,
        "searchDate":this.dateValue,
        
      }
      _ipCheck.getIpCheckList(params)
      .then(res => {
        this.tableData = res.data.list
        this.totalNum = res.data.total
      })
    },
  },
  created(){
    this.dateValue = this._mapping.date_format2(new Date())
    this.getIpCheckList()

  }
}
</script>
<style lang="scss" scoped>
.wrap{
  .table{
    margin-top: 10px;
    margin-bottom: 25px;
  }
}
</style>